package Bi_Tree.three_traversal;

import Bi_Tree.TreeNode;

import java.util.ArrayList;
import java.util.List;

public class lc144_recursion {
    public List<Integer> preorderTraversal(TreeNode root) {
        List<Integer> list=new ArrayList<>();
        preorder(root,list);
        return list;

    }
    public void preorder(TreeNode root, List<Integer> result) {
        if(root==null) {
            return;
        }else{
            result.add(root.val);
            preorder(root.left,result);
            preorder(root.right,result);
        }
    }
}
